home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 4
/
Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso
/
Development
/
General
/
MWC & CodeResources
/
ReadMe
< prev
next >
Wrap
Text File
|
1994-01-13
|
4KB
|
87 lines
=================================================
TechNote: Metrowerks C/C++ 68k and Code Resources
=================================================
Created 13-Jan-94 by Andreas Hommel
The files in this folder are some examples for creating code resources, DAs and
device drivers with Metrowerks C. MWC supports global data in code resources. This
global data is accessed using the A4 register. However the programmer is responsible
for setting this A4 register before using global data (see example files).
MWC also supports multiple code segments. To unload a code segment use the
pascal void UnloadA4Seg(void *); function just as you would use the UnloadSeg() function
in an application.
All code resources, DAs and device drivers will be entered through the main function.
WDEF.c is a skeleton WDEF code resource that shows how to use global data within code
resources and how to handle callback functions.
DRVR_DA.c is a skeleton device driver / DA that shows how to dispatch from main.
"SetUpA4.h" and "A4Stuff.h" are some header files that did not make it into the DR1
CodeWarrior release (the "A4Stuff.h" definitions were previously defined in MacHeaders.c
and the "SetUpA4.h" stuff was missing).
Libraries and code resources/DAs/Drivers:
-----------------------------------------
Any library that uses global/static data must have been compiled as an A4 library when
beeing used in a code resources/DA/Driver. You cannot use ANSI.lib, CPlusPlus.Lib... .
Use ANSIA4.lib, CPlusPlusA4.Lib... instead. Only MacOS.lib is a universal library that
can be used in both applications and code resources/DAs/Drivers. To create an A4 library
Make a library using a project where the project type is set to CodeResource.
Single segment code resources/DAs/Drivers:
------------------------------------------
• one segment
• near code/data only
• maximum 32k code
• maximum 32k data
• only simple constant initializations are supported. This implies:
no pointer inits as in "char *ptr="foo";" (however "char arr[]="foo";" works fine).
no virtual function tables
Multi segment code resources/DAs/Drivers:
-----------------------------------------
• multiple segments
• near and far code/data
C++ and code resources/DAs/Drivers:
-----------------------------------
• initialization code is not yet supported. This implies:
no global static class objects with constructors or destructors.
no global static data objects with non-constant initialization
(non-constant pointer initialization is allowed "char *ptr="foo";")
The following Resources are generated when creating:
----------------------------------------------------
single segment LDEF resource 123:
LDEF 123 // code resource
multi segment CDEF resource 123 (3 segments):
CDEF 123 / CDEx 123 // code resource segment 1 + relocation resource
CDEc 124 / CDEx 124 // code resource segment 2 + relocation resource
CDEc 125 / CDEx 125 // code resource segment 3 + relocation resource
single segment driver/DA 123;
DRVR 123 // the driver/DA
multi segment driver/DA 123 (3 segments):
DRVR 123 // generic driver/DA code
DRVc 123 / DRVx 123 // driver segment 1 + relocation resource
DRVc 124 / DRVx 124 // driver segment 2 + relocation resource
DRVc 125 / DRVx 125 // driver segment 3 + relocation resource
Code Resource Header:
---------------------
The header of a code reource will always look like this:
// bra.s __Startupcode__
// dc.w 0
// dc.l Code Resource Type // WDEF/CDEF/MDEF/LDEF/XTND...
// dc.w Code Resource ID // resource id
// dc.w Version (0)
// __Startupcode__:
// jmp main